from zentao_test.base.base_operation import PageTools
import time

class addUser(PageTools):
    success_ele = 'a[data-toggle="dropdown"]'

    zuzhi_ele = '[id="menucompany"]'
    tianjia_ele = '[id="submenuaddUser"]'

    username_ele = '[id="account"]'
    true_name = '[name="realname"]'
    password = '[id="password1"]'
    again_password = 'input[id="password2"]'
    my_password = '[id="verifyPassword"]'
    baocun_button = '[id="submit"]'

    tept1_ele = '[id="value1"]'
    tept2_ele = '[class="w-160px"] div[class="btn-group"] button[id="submit"]'
    addUser_success_ele = 'tr[class="text-center"]'

    def addUser_action(self, username, true_name, password, again_password, my_password):
        self.by_css(self.zuzhi_ele).click()
        self.by_css(self.tianjia_ele).click()
        time.sleep(1)
        self.by_css(self.username_ele).send_keys(username)
        time.sleep(1)
        self.by_css(self.true_name).send_keys(true_name)
        time.sleep(1)
        self.by_css(self.password).send_keys(password)
        time.sleep(1)
        self.by_css(self.again_password).send_keys(again_password)
        time.sleep(1)
        self.by_css(self.my_password).send_keys(my_password)
        time.sleep(1)

        self.by_css(self.baocun_button).click()
        time.sleep(2)


    def get_success_text(self):
        return self.by_css(self.success_ele).text